<template>
  <div id="OrdersTitle" ref="index">
    <v-tableTitle
      :btnConfig="btnConfig"
      :tableSelectData="tableSelectData"
      :title="$t('out.ymxfjimport')"
      @upFile="upFile"
      @cancel="cancel"
    ></v-tableTitle>
    <v-details
      :inputConfig="inputConfig"
      :detailData="inputData"
      :rules="rules"
      ref="input"
    ></v-details>
  </div>
</template>

<script>
import details from "@/components/commons/Detail";
import baseMixin from "@/mixins/BaseMixin";
import tableTitle from "@/components/commons/TableTitle";

export default {
  props: {},
  mixins: [baseMixin],
  name: "bhrwscQuery",
  data() {
    return {
      selectData: {},
      inputData: {
        type: "",
      },
      tableSelectData: [],
    };
  },

  computed: {
    btnConfig() {
      return [
        { label: this.$t("common.return"), invalid: "cancel" },
        { type: "file1", label: this.$t("common.import"), invalid: "file" },
      ];
    },
    inputConfig() {
      return [
        [
          {
            type: "select",
            label: this.$t('out.appendtype'),
            props: "type",
            options: this.getOptions("codelkup/ORDERAPPENDTYPE"),
          },
        ],
      ];
    },
    rules() {
      return {};
    },
  },
  methods: {
    screen() {
      this.$refs.index.style.width = "100%";
      this.$refs.index.style.height = "100%";
      this.$refs.index.style.position = "fixed";
      this.$refs.index.style.top = "0";
      this.$refs.index.style.left = "0";
      this.$refs.index.style.zIndex = "10";
      this.$refs.index.style.background = "#fff";
    },
    async upFile(data) {
      try {
        let res = await this.$api.post(
          "/importYmxPrintFj/" +
            this.inputData.type +
            "/" +
            this.selectData.orderkey +
            "/" +
            this.selectData.externorderkey,
          data
        );
        
          this.$message.success(res.returnMgr);
          this.$router.push({ name: "ymxprintDeawer" });
        
      } catch (e) {
        this.$message.error(e);
      }
    },
    cancel() {
      this.$router.push({ name: "ymxprintDeawer" });
    },
  },
  mounted() {
    this.selectData = this.$store.state.routeData;
  },
  watch: {},
  components: {
    "v-details": details,
    "v-tableTitle": tableTitle,
  },
};
</script>

<style scoped></style>
